import request from '@/Utils/fecth'
import { address } from '@/Utils/apiConfig'

export async function getRelayChainStatistics() {
  return request().get(`${address.crossChain.relayChain.statistic}`)
}

export async function listContracts(params) {
  return request().get(`${address.crossChain.contracts.list}`, {
    params,
  })
}

export async function listCommunicationChains(params) {
  return request().get(`${address.crossChain.communicationChains.list}`, {
    params,
  })
}

export async function listConsortiums() {
  return request().get(`${address.leagueManagement.leagueList}`)
}

export async function listChannelOfConsortium(consortiumId) {
  return request().get(`${address.leagueManagement.getChannelListAll.format({ consortiumId })}`)
}

export async function createCommunicationChain(body) {
  return request().post(address.crossChain.communicationChains.list, body)
}

export async function createContracts(data) {
  return request().post(address.crossChain.contracts.list, data)
}

export async function getCommunicationInfo(id) {
  return request().get(`${address.crossChain.communicationChains.list}/${id}`)
}

export async function listDeployedChannels(params) {
  return request().get(`${address.crossChain.deployedChannels}`, {
    params,
  })
}

export async function createApplication(body) {
  return request().post(address.crossChain.applications.list, body)
}

export async function listApplications(params) {
  return request().get(address.crossChain.applications.list, {
    params,
  })
}

export async function operateApplication(id, applicationId, data) {
  return request().post(`${address.crossChain.communicationChains.operateApplication.format({ id, applicationId })}`, data)
}

